package com.bc.commonentity.enums;

import com.bc.commoncore.util.CookieUtils;
import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.log.LogDetailHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * api-http 返回值公用 enum
 * ==========================
 * 0~9999: common error 使用， 0: fail,1: success;
 * ==========================
 * 1000~19999: user 相关业务使用;
 * ==========================
 *
 * @author CaoHeYang
 * @date 2015-0909
 */
public enum HttpReturnRnums {
    /**
     * 成功
     */
    Success(1, "成功", "success"),
    /**
     * 系统错误
     */
    SystemError(-1, "系统故障，请稍等", "system error,please try again"),
    /**
     * 参数错误
     */
    ParaError(-2, "参数错误", "parameter error"),

    NOT_LOGIN(-3, "请先完成登录后查看", "please log in first"),
    FILE_MAXLENGTH(-4, "文件过大不符合要求，请重新上传", "the uploaded file is to large,please try again"),
    FILE_FORMAT_ERROR(-5, "暂不支持该格式文件，请重新选择", "incorrect file format,please try again"),
    UPLOAD_NON(-6, "文件上传失败，请按照要求上传", "file upload error,please try again"),
    CHECK_CODE_ERROR(-7, "校验码错误，请重新输入", "incorrect password,please try again"),
    /**
     * 注册邮箱已经使用
     */
    EMAIL_IS_EXIST(1000, "该邮箱已注册", "this e-mail address already exists"),
    PASSWD_IS_EMPTY(1001, "密码为空，请填写", "password field cannot be left empty"),
    PASSWDREP_IS_EMPTY(1002, "二次校验密码为空，请填写", "password confirmation field cannot be left empty"),
    PASSWD_NOT_EQUAL(1003, "两次密码不一致，请核对后修改", "passwords do not match,please try again"),
    VCODE_IS_EMPTY(1004, "请输入正确的验证码", "please enter the verification code"),
    LOGON_NAME_PWD_NET_MATCH(1005, "登录账户和密码不匹配，请核对修改", "incorrect e-mail or password,please try again"),
    USER_NOT_EXIST(1006, "用户不存在，请检查账号是否正确", "this user doesn't exist,please try again"),
    USER_NOT_ACTIVATE(1007, "用户未激活，请先完成账户激活", "this user isn't activated yet,please activate first"),
    USER_ELITS_EXIST(1008, "您已经是业务/代码专家", "you already are business/code expert"),
    USER_ELITS_AUTH_ERROR(1009, "专家信息尚未审核通过，暂时不能发表专业评价", "expert information has not been approved,temporary cannot publish the commentary"),
    USER_ACCOUNT_ERROR(1010, "账户异常，请检查", "account error,please try again"),
    USER_ACCOUNT_PWD_ERROR(1011, "交易密码错误，请重新输入", "incorrect transaction password,please try again"),
    USER_ELITS_NOTEXIST(1012, "当前业务/代码专家不存在", "this business/code expert doesn't exist"),
    USER_BUYER_KYC_NOT_AUTH_STATUS(1013,"请完善您的KYC信息","please complete your KYC information"),

    GOOGLE_AUTH_ACCOUNT_IS_EXIST(1101, "您已经绑定google auth", "you have already connected Google Authenticator"),
    GOOGLE_AUTH_ACCOUNT_NOT_EXIST(1102, "您还未绑定google auth", "you haven't connected Google Authenticator yet"),
    GOOGLE_AUTH_AUTHORIZATION_FAILED(1103, "google auth验证失败，请重新输入验证", "invalid Google Authenticator code"),
    WALLET_IS_EXIST(1201, "钱包地址已经存在", "this wallet address already exists"),

    PROJECT_NOT_EXISTS(2000, "项目不存在", "this project doesn't exist"),
    PROJECT_INSERT_ERROR(2001, "项目信息未保存成功，请核查", "project's information haven't been saved,please try again"),
    PROJECT_UPDATE_ERROR(2002, "项目信息更新失败，请核查", "project's information update failed,please try again"),
    PROJECT_TAG_LENGTH_ERROR(2003, "标签内容过长，请按要求输入", "the tag is too long,please try again"),
    PROJECT_TAG_COUNTER_ERROR(2004, "每人每个项目最多贴三个标签", "projects and people cannot exceed three tags"),
    PROJECT_TAG_COUNTER_EXISTS(2005, "您的标签已存在，请重新编辑", "this tag already exists,please try again"),
    PROJECT_EXISTS_FOLLOW_GOOD(2006, "您已点赞", "liked"),
    PROJECT_EXISTS_FOLLOW_DESPISE(2007, "您已踩过", "followwings"),
    PROJECT_COUNTRY_NOT_BUY(2008,"您所有的国家不可购买该项目","Sorry, your country cannot purchase this project"),

    CEOKYC_AUTHSUCCESS(3000, "KYC审核已通过，暂不可修改", "KYC application has been approved,temporary cannot be changed"),

    WITHDRAW_AUTH(4000, "操作过快，请稍等", "operating too fast,please try again"),
    ELITES_EXISTS_FOLLOW(5000, "您已经为该专家点赞", "you hava already like this expert"),

    ;
    private int value = 0;
    private String desc;
    private String endesc;

    private HttpReturnRnums(int value, String desc, String endesc) { // 必须是private的，否则编译错误
        this.desc = desc;
        this.endesc = endesc;
        this.value = value;
    }

    public int value() {
        return this.value;
    }

    public String desc() {
        return this.desc;
    }

    public String endesc() {
        return this.endesc;
    }

    public static HttpReturnRnums getEnum(int index) {
        for (HttpReturnRnums c : HttpReturnRnums.values()) {
            if (c.value() == index) {
                return c;
            }
        }
        return null;
    }
}
